#include "data.h"

z_typeid z_typeid_null = 0;
z_size z_size_empty = 0;

z_data z_data_init(z_typeid t, z_size s)
{
	z_data tmp = {
		t,
		s,
		NULL
	};

	return tmp;
}

int z_data_release(z_data d)
{
	if (d.src != NULL)
		free(d.src);
	return 0;
}

z_typeid z_data_typeid_get(z_data *d)
{
	return d->tid;
}

z_typeid z_data_typeid_set(z_data *d, z_typeid t)
{
	return (d->tid = t);
}

z_size z_data_size_get(z_data *d)
{
	return d->size;
}

z_size z_data_size_set(z_data *d, z_size s)
{
	return (d->size = s);
}

void *z_data_src_get(z_data *d)
{
	return d->src;
}

void *z_data_src_set(z_data *d, void *s)
{
	return (d->src = s);
}

int z_data_retrieve_query_code(z_data *d)
{
	return (int)d->src;
}

int z_data_assign_query_code(z_data *d, int c)
{
	return (int)(d->src = (void *)c);
}

int z_data_eq(z_data *a, z_data *b)
{
	return ((a->tid == b->tid && a->size == b->size) && a->src == b->src);
}

int z_data_null(z_data *d)
{
	return ((d->tid == 0 && d->size == 0) && d->src == NULL);
}
